import axios from 'axios'

// 添加模拟数据
const mockServiceTypes = [
  { id: 1, name: '标准洗涤', description: '普通衣物的标准洗涤服务', price: 15.00 },
  { id: 2, name: '高级洗涤', description: '适用于特殊面料的高级洗涤服务', price: 30.00 },
  { id: 3, name: '快速洗涤', description: '当日取送的快速洗涤服务', price: 25.00 },
  { id: 4, name: '干洗服务1', description: '专业干洗服务', price: 40.00 }
];

export function getServiceTypes() {
  return axios.get('/api/service/list')
    .then(res => res.data)
    .catch(() => {
      console.log('使用服务类型模拟数据');
      return {
        code: 200,
        message: '成功',
        data: mockServiceTypes
      };
    });
}

export function getServiceTypeById(id) {
  return axios.get(`/api/service/detail?id=${id}`).then(res => res.data)
}

export function createServiceType(data) {
  return axios.post('/api/service/create', data).then(res => res.data)
}

export function updateServiceType(data) {
  return axios.put('/api/service/update', data).then(res => res.data)
}

export function deleteServiceType(id) {
  return axios.delete(`/api/service/delete?id=${id}`).then(res => res.data)
} 